package com.hystrix;

import com.hystrix.command.FallbackCommand;
import com.hystrix.command.HelloCommand;
import com.netflix.config.ConfigurationManager;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * 请先启动当前项目的Spirng Boot
 * Created by earl on 2018/4/28.
 */
public class TestFallback {

        public static void main(String [] args){
            testFallback();
        }


        //测试回退
        public static  void testFallback(){
            // 断路器被强制打开，导致回退
            ConfigurationManager.getConfigInstance(). setProperty(
                    "hystrix.command.default.circuitBreaker.forceOpen", "true");
            FallbackCommand c = new FallbackCommand();
            c.execute();
            // 创建第二个命令，断路器关闭
            ConfigurationManager.getConfigInstance().setProperty(
                    "hystrix.command.default.circuitBreaker.forceOpen", "false");
            FallbackCommand c2 = new FallbackCommand();
            c2.execute();
        }



}
